package com.globallogic.javatrainings.sergiiivanov.view;

import com.globallogic.javatrainings.sergiiivanov.model.Const;
import com.globallogic.javatrainings.sergiiivanov.resources.Formating;
import com.globallogic.javatrainings.sergiiivanov.resources.Messages;

public class CoursesManagementPage extends GUI {
    public void addNewCourseDiscipline(String[] disciplines) {
        show("Select Discipline");
        showArrayAsList(disciplines);
    }

    public void addNewCourseName(String header) {
        newPage();
        show(header + " > " + "Courses");
        show("Adding new course");
        show("Enter course title:");
    }

    public void addNewLectureDescription() {
        show("Enter lecture description (enter single space to skip)");
    }

    public void addNewLectureDiscipline(String[] types) {
        show("Select lecture type");
        showArrayAsList(types);
    }

    public void addNewLectureTitle(String selectedCourseTitle) {
        show("Adding new lecture to " + selectedCourseTitle);
        show("Enter lecture title (topic)");
    }

    public void addScore() {
        show("Define the score from " + Const.MIN_SCORE + " to "
                + Const.MAX_SCORE);
    }

    public void addScoreErrorValue() {
        showWarning("Score not added - Incorrect score value");
    }

    public void addScoreLectureSelection(String[] lectures) {
        show("Select lecture or lesson");
        showLineOfList(Messages.MENU_BACK, 0);
        showArrayAsList(lectures, 1);
    }

    public void addScoreReason() {
        show("Specify the reason for this score");
    }

    public void addScoreStudentSelection(String[] students) {
        show("\nAdding new score to student...");
        show("Select student");
        showLineOfList(Messages.MENU_BACK, 0);
        showArrayAsList(students, 1);
    }

    public void confirmDeleteCourse() {
        show("You are about to remove this course\n"
                + "   this could not be undone\n"
                + "   All related information will be lost\n"
                + "Are you sure to delete this course?");
    }

    public void confirmDisenroll(String course, String student) {
        show("You are about to disenroll " + student + " from course " + course
                + "\n Are you sure to continue?(Y/N)");

    }

    public void courseDetails(
            String title,
            String name,
            String discipline,
            String teacher
            ) {
        show(title + " > course details");
        show(Messages.COURSE_DETAILS_TITLE + Formating.TABLE_SPACER + name);
        show(Messages.COURSE_DETAILS_DISCIPLINE + Formating.TABLE_SPACER + discipline);
        show(Messages.COURSE_DETAILS_TEACHER + Formating.TABLE_SPACER + teacher);
    }

    public void courseDetailsMenu(String[] menu) {
        showArrayAsList(menu);
    }

    public void coursesList(String header, String[] courses,
            String[] menu) {
        newPage();
        show(header + " > " + "Courses");
        showLineOfList(Messages.MENU_BACK, 0);
        showArrayAsList(courses, 1);
        showLineOfList("Add new course", courses.length + 1);
    }

    public void deleteLectureConfirmation(String universityTitle,
            String courseTitle, String lectureTitle) {
        show("You are about to remove lecture " + lectureTitle
                + " from the course " + courseTitle + " of " + universityTitle);
        show("Are you sure to continue? Y/N");
    }

    public void enrolledStudentsList(String[] students) {
        showLineOfList(Messages.MENU_BACK, 0);
        show("Enrolled students:");
        showArrayAsList(students, 1);
        show("Select student to disenroll from the course, or");
        showLineOfList("Enroll another student", students.length + 1);
        showLineOfList("Add score record", students.length + 2);
        showLineOfList("Show scores", students.length + 3);
    }

    public void enrollStudent(String[] allStudents) {
        show("Select student to enroll");
        showArrayAsList(allStudents);
    }

    public void groupScoresTable(String[][] scores) {
        show("Group scores:");
        showTableOrdered(scores, 1);
        showLineOfList(Messages.MENU_BACK, 0);
    }

    public void lectureDetailsEditMenu(String[] menu) {
        showArrayAsList(menu);
    }

    public void lectureDetails(
            String universityTitle,
            String selectedCourseTitle,
            String name,
            String type,
            String description,
            String room) {
        show(universityTitle + " > course" + selectedCourseTitle + " > edit lecture ");
        show(Messages.LECTURE_DETAILS_TITLE + Formating.TABLE_SPACER + name);
        show(Messages.LECTURE_DETAILS_TYPE + Formating.TABLE_SPACER + type);
        show(Messages.LECTURE_DETAILS_DESCRIPTION + Formating.TABLE_SPACER + description);
        show(Messages.LECTURE_DETAILS_ROOM + Formating.TABLE_SPACER + room);
    }

    public void lecturesList(String universityTitle,
            String courseTitle, String[] lectures) {
        show(universityTitle + " > Course " + courseTitle + " > Lectures");
        showLineOfList(Messages.MENU_BACK, 0);
        showArrayAsList(lectures, 1);
        show("Select lecture for edit or");
        showLineOfList("Add new lecture", 1 + lectures.length);
    }

    public void selectTeacher(String[] teachersList) {
        show("Select teacher to assign");
        showArrayAsList(teachersList);
    }

    public void appointRoomSelectBuilding(String[] buildings) {
        show("Appointing room for the lecture");
        show("Select building");
        showArrayAsList(buildings);
    }

    public void appointRoomSelectRoom(String[] roomsList) {
        show("Select room");
        showArrayAsList(roomsList);
    }

    public void appointRoomAppointAll() {
        show("Do you want to appoint this room for all lectures of this course? \n" +
                "Y - appoint all lectures\n" +
                "N - assign only one lecture");
    }

    public void showStillUnassignedLectures(String[] lecturesList, String[] errors) {
        show("Lectures below are not appointed due to some errors:");
        for (int i = 0; i < lecturesList.length; i++) {
            show(lecturesList[i] + " is not appointed due to " + errors[i]);
        }
        show("You need to finish appointments manually\n 0 - Ok");
    }
}
